
const Cesium = window.Cesium;
import { formarColor, COLOR } from "../../Config";


class Link {
    constructor(Entity, positionA, positionB, options) {
        if (!Entity) {
            throw new Error('至少传入一个 Entity 对象');
        };
        this.Entity = Entity;
        this.options = options;

        this.positions = [positionA, positionB];
        var _update = () => this.positions;
        this.Entity.polyline = {
            positions: new Cesium.CallbackProperty(_update, false),
            arcType: this.options.ArcType || Cesium.ArcType.NONE,
            material: formarColor(this.options.color || COLOR.DEFAULT),
            width: this.options.width || 1,
        }
    }
    setPosition(positionA, positionB) {
        this.positions = [positionA, positionB];
    }
    set show(type) {
        this.Entity.polyline.show = !!type;
    }
    get show() {
        return this.Entity.polyline.show
    }
}


export { Link }
